﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Net.Mail;

namespace Securfid
{
    class Configs
    {
        //Variables de la classe Lectures
        private int id_config;
        private int temps_lectures;
        private int temps_alarme;
        private string email_de;
        private string email_a;
        private bool stop_alarme;

        //Intialisation
        public void Initialise(int I, int L, int A, string DE, string EA, bool S)
        {
            this.id_config = I;
            this.temps_lectures = L;
            this.temps_alarme = A;
            this.email_de = DE;
            this.email_a = EA;
            this.stop_alarme = S;
        }

        //Accesseurs
        public int Gettemps_lectures()
        {
            return temps_lectures;
        }
        public int Gettemps_alarme()
        {
            return temps_alarme;
        }
        public string GetEmail_De()
        {
            return email_de;
        }
        public string GetEmail_A()
        {
            return email_a;
        }
        public bool GetStop_alarme()
        {
            return stop_alarme;
        }

        public static void email(string body, string local, string email, Configs config)
        {
            try
            {
                string from = config.GetEmail_De();
                string subject = "Alarme SecurFID au local ";
                subject += local;

                MailMessage mailMsg = new MailMessage(from, email, subject, body);

                // Init SmtpClient and send
                SmtpClient smtpClient = new SmtpClient("relais.cegepsherbrooke.qc.ca");
                smtpClient.Send(mailMsg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

        }
    }
}
